package com.github.yeecode.mybatisdemo;

import com.github.yeecode.mybatisdemo.model.SeasonEnum;

import java.time.DayOfWeek;
import java.util.*;

/**
 * @author : wushikai
 * <p>
 * date : 2021-02-08
 */
public class EnumMapDemo {


    public static void main(String[] args) {

        HashMap<Class, String> hashMap = new HashMap<>();
        hashMap.put(Integer.class, "sss");

        Map<DayOfWeek, String> map = new EnumMap<>(DayOfWeek.class);
        map.put(DayOfWeek.MONDAY, "星期一");
        map.put(DayOfWeek.TUESDAY, "星期二");
        map.put(DayOfWeek.WEDNESDAY, "星期三");
        map.put(DayOfWeek.THURSDAY, "星期四");
        map.put(DayOfWeek.FRIDAY, "星期五");
        map.put(DayOfWeek.SATURDAY, "星期六");
        map.put(DayOfWeek.SUNDAY, "星期日");
        System.out.println(map);
        System.out.println(map.get(DayOfWeek.MONDAY));


        EnumMap<SeasonEnum, String> seasonMap = new EnumMap<>(SeasonEnum.class);
        seasonMap.put(SeasonEnum.SPRING, "春天");
        seasonMap.put(SeasonEnum.SUMMER, "夏天");
        seasonMap.put(SeasonEnum.AUTUMN, "秋天");
        seasonMap.put(SeasonEnum.WINTER, "冬天");
        System.out.println(seasonMap.toString());
        System.out.println(seasonMap.get(SeasonEnum.SUMMER) + SeasonEnum.SUMMER.getValue());

        System.out.println("-----------------------------------------------------------------");


        //1.创建一个包含Session（枚举类）里所有枚举值的EnumSet集合
        EnumSet e1 = EnumSet.allOf(SeasonEnum.class);
        System.out.println(e1);//[SPRING, SUMMER, FAIL, WINTER]

        //2.创建一个空EnumSet
        EnumSet e2 = EnumSet.noneOf(SeasonEnum.class);
        System.out.println(e2);//[]

        //3. add()空EnumSet集合中添加枚举元素
        e2.add(SeasonEnum.SPRING);
        e2.add(SeasonEnum.SUMMER);
        System.out.println(e2);//[SPRING, SUMMER]

        //4. 以指定枚举值创建EnumSet集合
        EnumSet e3 = EnumSet.of(SeasonEnum.SPRING,SeasonEnum.AUTUMN);
        System.out.println(e3);//[SPRING, FAIL]

        //5.创建一个包含从from枚举值到to枚举值范围内所有枚举值的EnumSet集合。
        EnumSet e4 = EnumSet.range(SeasonEnum.SPRING,SeasonEnum.AUTUMN);
        System.out.println(e4);//[SPRING, SUMMER, FAIL]

        //6.创建一个其元素类型与指定EnumSet里元素类型相同的EnumSet集合，
        //  新EnumSet集合包含原EnumSet集合所不包含的枚举值
        EnumSet e5 = EnumSet.complementOf(e4);
        System.out.println(e5);//[WINTER]


    }
}
